package com.ymatou.iapi.live.testcase;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.live.parameter.GetHotWordsBean;
import com.ymatou.iapi.live.service.GetHotWordsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;

public class Ts_GetHotWords {
	
	private static GetHotWordsBean getHotWordsBean;
	private static GetHotWordsCall getHotWordsCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取热词");
	}

	@Before
	public void caseUp() throws Exception {
		getHotWordsBean = new GetHotWordsBean();
		getHotWordsCall = new GetHotWordsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getHotWordsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetLiveInfo_001() {
		 Logger.start(true,"判断接口status是否为200");
		 try {
			 getHotWordsBean.setNum(50);
			 
			 getHotWordsCall.setData(getHotWordsBean);
			 getHotWordsCall.callService();
			 
			 int status = getHotWordsCall.getStatus();
			 //JSONObject object = new JSONObject (getHotWordsCall.getResult().getJSONArray("hotWords").get(0).toString());
			 
			 Logger.comment("getHotWordsCall send:" + getHotWordsCall.getEntityString());
			 Logger.comment("getHotWordsCall response:" + getHotWordsCall.getReturnData());
			 
			 Logger.verifyEquals(200, status, "判断接口status是否为200");
			 /*Logger.verifyNotNull(getHotWordsCall.getResult(), "验证result是否为空");
			 Logger.verifyNotNull(getHotWordsCall.getResult().getJSONArray("hotWords").length(), "验证关键词数组是否为空");
			 Logger.verifyNotNull(object.get("hotWord"), "验证搜索关键字是否为空");*/
			 
		 } catch (Exception e) {
			 Logger.fail(e);
		 }
	 }
}
